#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:homework8_1.py
# author:wmf
# datetime:2021/5/6 14:07
# software: PyCharm
'''
this is function description
'''
# import module your need

# 1  有100个同学的分数：数据请用随机函数生成；
#     A  利用多线程程序（比如，5个线程，每个线程负责输出20条记录），快速输出这100个同学的信息；
#    B 利用线程池来实现；


from random import randint
import threading

score = [randint(0, 100) for _ in range(100)]
for x in score:
    print(x, end=' ')
print()


class A_thread(threading.Thread):
    def __init__(self, name, counter):
        threading.Thread.__init__(self)
        self.name = name
        self.counter = counter

    def run(self):
        for i in range(0, 20):
            print("%s:第%s位同学的成绩为:%s" % (self.name, self.counter + i+1, score[self.counter+i]))


if __name__ == "__main__":
    a_thread1 = A_thread("a_thread1", 0)
    a_thread2 = A_thread("a_thread2", 20)
    a_thread3 = A_thread("a_thread3", 40)
    a_thread4 = A_thread("a_thread4", 60)
    a_thread5 = A_thread("a_thread5", 80)
    a_thread1.start()
    a_thread2.start()
    a_thread3.start()
    a_thread4.start()
    a_thread5.start()

